<?php
/**
 * Created by JetBrains PhpStorm.
 * User: user
 * Date: 3/16/12
 * Time: 5:41 PM
 * To change this template use File | Settings | File Templates.
 */
class Admin_Model_Article extends Zend_Db_Table_Abstract{

    protected $_name = 'bai_viet';

    public function getArticle($ma){
        $ma = (int)$ma;
        $row = $this->fetchAll('ma = '.$ma);
        if(!$row){
            throw new Exception ("Không tìm thấy bài viết có mã bằng: $ma") ;
        }
        return $row->toArray();
    }
    public function addArticle($ma_loai, $ma_nguoi_dung, $tieu_de, $noi_dung_tom_tat,
                                $noi_dung_chi_tiet, $ngay_tao, $so_lan_xem, $trang_thai, $hinh){
        $data = array(
            'ma_loai' => $ma_loai,
            'ma_nguoi_dung' => $ma_nguoi_dung,
            'tieu_de' => $tieu_de,
            'noi_dung_tom_tat' => $noi_dung_tom_tat,
            'noi_dung_chi_tiet' => $noi_dung_chi_tiet,
            'ngay_tao' => $ngay_tao,
            'so_lan_xem'=>$so_lan_xem,
            'trang_thai'=>$trang_thai,
            'hinh'=>$hinh,
        );
        $this->insert($data);
    }
}
 
